package com.xiaoshuidi.cloud.module.guanwang.framework.enums;

import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import com.xiaoshuidi.cloud.module.guanwang.controller.admin.guanwang.configvo.*;
import com.xiaoshuidi.cloud.module.guanwang.service.GuanWangConfiguration;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.catalina.Host;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum GuanWangConfigEnum {

    BANNER("首页Banner", 1, BannerVO.class),
    HOME_ABOUT_US("首页关于我们", 2, HomeAboutUsVO.class),
    COMPANY_LOGO("企业LOGO", 3, CompanyLogoVO.class),
    QR_CODE("公众号、APP、小程序二维码", 4, QrCodeVO.class),
    COMPANY_RENTAL_HOUSING("企业租房", 5, CompanyRentalHousingVO.class),
    ABOUT_US("关于我们-关于我们(视频、图片)", 6, AboutUsVO.class),
    CONTACT_US("联系我们-地图图片", 7, ContactUsVO.class),
    WEBSITE_LINK("网址链接", 8, WebsiteLinkVO.class),
    TOP_BAR("顶部导航栏", 9, TopBarVO.class),
    BOTTOM_BAR("底部导航栏", 10, BottomBarVO.class),
    BOTTOM_TEXT("底部文字", 11, BottomTextVO.class);

    private final String name;
    private final Integer index;
    private final Class<? extends GuanWangConfiguration> configClass;

    public static String getNameByIndex(Integer value){
        GuanWangConfigEnum guanWangConfigEnum = Arrays.stream(GuanWangConfigEnum.values()).filter(p -> p.index.equals(value)).findFirst().orElse(null);
        if(ObjectUtil.isEmpty(guanWangConfigEnum)){
            return "";
        }
        return guanWangConfigEnum.getName();
    }

    public static GuanWangConfigEnum getByIndex(Integer indexId) {
        return (GuanWangConfigEnum) ArrayUtil.firstMatch((o) -> {
            return o.getIndex().equals(indexId);
        }, values());
    }
}
